#pragma once 
#include<iostream>
#include<pthread.h>
class LockGuard //互斥量RAII
{
    public:
    LockGuard(pthread_mutex_t& mutex)
    :_mutex(mutex)
    {
        pthread_mutex_init(&_mutex,nullptr);
        pthread_mutex_lock(&_mutex);
    }
    ~LockGuard()
    {
        pthread_mutex_unlock(&_mutex);
        pthread_mutex_destroy(&_mutex);
    }
    private:
    pthread_mutex_t& _mutex;
};